package com.hehao.java_basic.recursion;

import java.util.Scanner;

public class recursion {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入n的值：");
        int num = scanner.nextInt();
        System.out.println(num + "的和为" + sum(num));
    }

    private static int sum(int num) {
        if (num == 1) {
            return 1;

        }
        int i = num * sum(num - 1);
        return i;
    }
}
